/**
 * 环节路由对应关系
 */


//环节路由配置
export const tacheRouter=[

    {code:1,path:'/homeIndex',name:'homeIndex',desc:'首页',remark:'首页'},

    {code:100,path:'/commonAppro',name:'commonAppro',desc:'综合任务',remark:'综合任务'},

    {code:1903,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'一次初级授权'},
    {code:1904,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'二次初级授权'},
    {code:1907,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'一次信贷初级授权'},
    {code:1908,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'二次信贷初级授权'},
    {code:1951,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'一次分行初级授权'},
    {code:1952,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'二次分行初级授权'},
    {code:1961,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'一次分行信贷初级授权'},
    {code:1962,path:'/primaryAppro',name:'primaryAppro',desc:'初级授权',remark:'二次分行信贷初级授权'},

    {code:1905,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'一次高级授权'},
    {code:1906,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'二次高级授权'},
    {code:1941,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'一次信贷高级授权'},
    {code:1942,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'二次信贷高级授权'},
    {code:1971,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'一次分行高级授权'},
    {code:1972,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'二次分行高级授权'},
    {code:1981,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'一次分行信贷高级授权'},
    {code:1982,path:'/heightAppro',name:'heightAppro',desc:'高级授权',remark:'二次分行信贷高级授权高级'},

    {code:1002,path:'/pageDiscriminate',name:'pageDiscriminate',desc:'版面识别',remark:'人工版面识别'},
    {code:1001,path:'/pageDiscriminate',name:'pageDiscriminate',desc:'版面识别',remark:'自动版面识别'},

    {code:1201,path:'/singleRecord',name:'singleRecord',desc:'整单录入',remark:'整单录入'},
    {code:1202,path:'/singleRecord',name:'singleRecord',desc:'整单录入',remark:'整单录入'},
    {code:1203,path:'/singleAppro',name:'singleAppro',desc:'整单仲裁',remark:'整单仲裁'},

    {code:1304,path:'/fragmentAppro',name:'fragmentAppro',desc:'碎片仲裁',remark:'碎片仲裁'},
    {code:102,path:'/cutRecord',name:'cutRecord',desc:'切片录入',remark:''},
    {code:103,path:'/cutRecord',name:'cutRecord',desc:'切片录入',remark:''},

    {code:1991,path:'/***',name:'',desc:'网点授权',remark:'网点授权'},

    {code:1501,path:'/tradeDetection',name:'',desc:'自动重复交易监测',remark:'自动重复交易监测'},
    {code:1502,path:'/manualMonitor',name:'',desc:'人工重复交易监测',remark:'人工重复交易监测'},
];


// 跳转环节任务定义路由
// 注意 当前路由跳转当前路由不可行
export function toTacheRouter(that,code,params) {
    let path=null;
    let name=null;
    let title=null;
    tacheRouter.forEach(val=>{
        if(code == val.code){
            path=val.path;
            name=val.name;
            title=val.desc;
            return;
        }
    });
    if(!path){
        console.log('无环节对应路由配置---》');
        return false;
    }
    let thisRouter = window.document.location.pathname;
    if(thisRouter == path){
        console.log('----本环节---'+path);
        that.initTask(params);
    }else{
        //根据路由跳转 修改路由标题
        let routerParams={parentTitle:'任务处理',title:title,routerName:name};
        trainUtil.$emit('updateRouterInfo',routerParams);
        that.$router.push({path:path,name: name,params:{task:params}});
    }
}

/**
 * 默认判断是否路由跳转规则
 * 初始 任务方法 initTask 固定
 * 初始 获取任务方法 initTaskIndex 固定
 * 初始 不获取任务方法 unGetTasks 固定
 * @returns {boolean}
 */
export function defaultJustRouter(that,resCode,res,isContinueTask) {
    if(res.isIntegratedTask == resCode.handTaskListPublic){ //挂起任务列表 综合
        console.log('获取挂起任务列表综合任务---》');
        toTacheRouter(that,resCode.commonTacheCode,res);
    }else if(res.isIntegratedTask == resCode.isIntegratedTask){ //综合任务
        if(res.bizData){
            console.log('获取到下一笔综合任务---》');
            toTacheRouter(that,res.tacheCode,res);
        }else{
            console.log('获取到下一笔综合任务 无任务状态---》');
            toTacheRouter(that,resCode.commonTacheCode,res);
        }
    }else if(res.isIntegratedTask == resCode.handTaskListPrivate){ //挂起任务列表 私有
        console.log('获取挂起任务列表 私有---》');
        that.$parent('doHungUpTasks',res.bizData);
    }else if(res.bizData){ //获取到私有  下一笔任务 安装综合任务方式 处理 高级获取初级授权页面
        console.log('获取一般任务---》');
        toTacheRouter(that,res.tacheCode,res);
    }else if(isContinueTask) { //重新获取任务
        console.log('重新获取任务---》');
        that.$emit('initTaskIndex');
    }else{ //跳转到私有获取任务页面
        console.log('不获取任务---》');
        that.$emit('unGetTasks');
    }

}

//获取配置路由
export function getTacheRouter(code) {
    let routerConfit;
    tacheRouter.forEach(val=>{
        if(code == val.code){
            routerConfit=val;
            return;
        }
    });
    return routerConfit;
}
